//
//  JCDeviceUtil.swift
//  JCPublicKit
//
//  Created by JasonLee on 2020/5/13.
//

import Foundation

class JCDeviceUtil: NSObject {
    // MARK: 判断是否全面屏
    /**
     判断是否全面屏
     */
    @objc static func isScreenTypeAllScreen() -> Bool {
        if #available(iOS 11.0, *) {
            guard let window = UIApplication.shared.keyWindow else { return false }
            if (UIApplication.shared.statusBarOrientation.isLandscape) {
                return window.safeAreaInsets.left > 0
            } else {
                return window.safeAreaInsets.top > 20
            }
        } else {
            // Fallback on earlier versions
            return false
        }
    }
}

extension UIScreen {
    /**
     判断是否全面屏
     */
    @objc static var jc_isAllScreenType: Bool {
        return JCDeviceUtil.isScreenTypeAllScreen()
    }
}
